import numpy as np
import sys
import os

src_path = os.path.realpath(sys.argv[1])
dst_path = os.path.realpath(sys.argv[2])
m, n, k = int(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5])

zhhao = np.fromfile(src_path, dtype=np.int32).reshape((m, n))
gt = np.fromfile(dst_path, dtype=np.int32).reshape((m, n))

diff = np.abs(zhhao-gt)
equal = np.all(gt==zhhao)

if not equal:
    print(f"## m {m} n {n} k {k} not equal {os.path.basename(src_path)} max {np.max(zhhao)} {os.path.basename(dst_path)} max {np.max(gt)} max_abs_diff {np.max(diff)}")
    # np.set_printoptions(threshold=np.inf)
    # print(f"{os.path.basename(src_path)} {zhhao}")
    # print(f"{os.path.basename(dst_path)} {gt}")
    sys.exit(-1)
else:
    print(f"## m {m} n {n} k {k} equal")

# gt = np.fromfile(dst_path, dtype=np.int32)
# # gt = np.fromfile(dst_path, dtype=np.float32)

# np.set_printoptions(threshold=np.inf)
# print(f"{os.path.basename(dst_path)} {gt}")

